package org.doubango.FrCall.Screens;

import org.doubango.FrCall.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class EmailRegister extends Activity {
	private EditText email;
	private EditText password;
	private Button eToFinish;
	private Button eBackToRegSelect;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.register_email);
		email = (EditText) findViewById(R.id.register_id);
		password = (EditText) findViewById(R.id.register_password);
		eToFinish = (Button) findViewById(R.id.e_to_finish);
		eBackToRegSelect = (Button) findViewById(R.id.email_reg_back_reg_select);
		
		eToFinish.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				if(validate()){
				Intent intent = new Intent(EmailRegister.this,EmailRegisterOk.class);
				startActivity(intent);
				finish();
				}
			}
		});
		
		eBackToRegSelect.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(EmailRegister.this,RegisterSelect.class);
				startActivity(intent);
				finish();
			}
		});
	}
	private boolean validate(){
		 String num= email.getText().toString();
		if(num.equals("")){
			Toast.makeText(this, "邮箱不能为空！", Toast.LENGTH_SHORT).show();
			return false;
		}
		if(!num.contains("@"))
		{
			Toast.makeText(this, "邮箱格式不正确！", Toast.LENGTH_SHORT).show();
			return false;
		}
		 String pw= password.getText().toString();
		if(pw.equals("")){
			Toast.makeText(this, "密码不能为空", Toast.LENGTH_SHORT).show();
			return false;
		}
		return true;
	}
	
}
